// 路由层级对应的菜单配置
export const menuOptions = {
  10: {
    name: "卡片组件",
    icon: "icon-apps",
  },
  20: {
    name: "盒子组件",
    icon: "icon-apps",
  },
};
// 路由配置数组，按页面层级配置
export const routesIndexArr = {
  10: [
    { en: "thCard", cn: "卡片1", tab: "0" },
  ],
  20: [
    { en: "thBox", cn: "盒子1", tab: "0" },
  ],
  // 999: [{ en: "login", cn: "登录" }],
};

// 路由白名单，不会清除缓存
export const whiteRoutes = [];

// 路由索引对象
export const routesIndexObj = {};

// 路由配置数组，按页面层级配置自动生成
const routes = [
  { path: "/", redirect: routesIndexArr["10"][0].en },
];

// 获取页面
const modules = import.meta.glob(["../views/**/*.vue"]);

// 循环配置路由
Object.keys(routesIndexArr).forEach((level) => {
  routesIndexArr[level].forEach((routeItem, idx) => {
    routesIndexObj[routeItem.en] = Number(level) + 0.1 * idx;
    routes.push({
      path: `/${routeItem.en + (routeItem.params || "")}`,
      name: routeItem.en,
      component: modules[`../views/${routeItem.path || routeItem.en}.vue`],
      meta: {
        title: routeItem.cn,
        // tab: routeItem.tab,
        // transitionName: "",
      },
    });
  });
});

export default routes;

